package com.tanhua.server.controller;

import com.tanhua.server.service.TaoHuaService;
import com.tanhua.server.vo.ChuanYin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/peachblossom")
public class TaoHuaController {
    @Autowired
    private TaoHuaService taoHuaService;

    @PostMapping
    public ResponseEntity<String> FaSongYuYin(@RequestParam("soundFile")MultipartFile multipartFile){
        try {
            String s = this.taoHuaService.FaSongYuYin(multipartFile);
            return ResponseEntity.ok(s);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }

    @GetMapping
    public ResponseEntity<ChuanYin> JieShouYuYin(){
        try {
            ChuanYin chuanYin=this.taoHuaService.JieShouYuYin();
            return ResponseEntity.ok(chuanYin);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
}
